import cookie from 'vue-cookie'

const loginapp = {
	state:{
		userName:cookie.get("username"),
		userRoid:cookie.get("userid")
	},
	mutations: {
		//设置 中文名
		SET_NAME: (state, name) => {
			state.name = name;
		},
		//设置角色id
		SET_ROLEID: (state, roleid) => {
				state.roleid = roleid;
		}
	},
	actions: {
		//退出操作
		LogoutAC({ commit }) {
			//设置 store
			commit("SET_NAME", "");
			commit("SET_ROLEID", "");
			cookie.delete("token");
			cookie.delete("name");
			cookie.delete("username");
			cookie.delete("userid");
		}
	}
}

export default loginapp;